/**
 * 封装了一些歌手页面的api
 */
import { commonParams, options } from './config'
import jsonp from 'common/js/jsonp'

export function getSingerList () {
  const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'

  const data = Object.assign({}, commonParams, {
    channel: 'singer',
    page: 'list',
    key: 'all_all_all',
    pagesize: 100,
    pagenum: 1,
    hostUin: 0,
    needNewCode: 0,
    platform: 'yqq'
  })
  return jsonp(url, data, options)
}

export function getSingerDetail (singerId) {
  const url = 'https://u.y.qq.com/cgi-bin/musicu.fcg'
  let opt = Object.assign({}, options, {
    name: 'getUCGI7480716618410095'
  })
  const data = Object.assign({}, commonParams, {
    callback: 'getUCGI7480716618410095',
    jsonpCallback: 'getUCGI7480716618410095',
    loginUin: 0,
    hostUin: 0,
    format: 'jsonp',
    notice: 0,
    platform: 'yqq',
    needNewCode: 0,
    data: JSON.stringify({
      comm: { ct: 24, cv: 0 },
      singer: {
        method: 'get_singer_detail_info',
        param: { sort: 5, singermid: singerId, sin: 0, num: 50 },
        module: 'music.web_singer_info_svr'
      }
    })
  })
  return jsonp(url, data, opt)
}
